package org.domain.pseample.session;

import java.util.HashMap;
import org.jboss.seam.annotations.In;
import org.jboss.seam.security.Credentials;
import org.apache.log4j.Logger;

public class ConferenceCenterManager {

	private static Logger logger = Logger
			.getLogger(ConferenceCenterManager.class);

	@In
	Credentials credential;

	private static ConferenceCenterManager conferenceCenterManager;

	public synchronized static ConferenceCenterManager instance() {
		logger.info("in conferencecentermanager");
		if (conferenceCenterManager == null) {
			conferenceCenterManager = new ConferenceCenterManager();
		}
		return conferenceCenterManager;
	}

	private HashMap<Integer, ConferenceCenter> conferenceCenters = new HashMap<Integer, ConferenceCenter>();

	synchronized public void setConferenceCenter(Integer dtmf, String admin) {

		ConferenceCenter cc = new ConferenceCenter();
		cc.setAdmin(admin);
		cc.createConferenceMembersList();
		conferenceCenters.put(dtmf, cc);
		logger.info("successfully added administrator" + admin + " with "
				+ dtmf + " in haspmap");

	}

	synchronized public ConferenceCenter getConferenceCenter(Integer dtmf) {
		logger.info("successfully retreived " + dtmf
				+ " from hashmap for conference " +conferenceCenters.get(dtmf));
		return conferenceCenters.get(dtmf);

	}

	synchronized public void removeConferenceCenter(Integer dtmf) {
		conferenceCenters.remove(dtmf);
		logger.info("removed " + dtmf + " from haspmap");
	}

}
